# models.py: 模型，数据库
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from exts import db

class User(db.Model):
    # 表名

    # 定义表字段

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    role = db.Column(db.String(10), nullable=False, default='student')  # 用户角色：student, teacher, admin
    username = db.Column(db.String(50), unique=True, nullable=False)
    name = db.Column(db.String(50), nullable=False)
    gender = db.Column(db.Boolean, nullable=False, default=True)
    grade = db.Column(db.String(20))  # 年级
    class_name = db.Column(db.String(20))  # 班级
    department = db.Column(db.String(50))  # 院系/部门